import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.SocketException;
import java.net.UnknownHostException;

/*
 * 
 */
public class UDPClient {
    public static void main(String[] args) throws IOException {
    	boolean work = true;
    	System.out.println("UDPClient");
        
        InetAddress address = InetAddress.getByName("192.168.0.122");
        int port = 8800;
        byte[] data = "helllo".getBytes();
        // 
        DatagramPacket packet = new DatagramPacket(data, data.length, address, port);
        // 
        DatagramSocket socket = new DatagramSocket();
        // 
        socket.send(packet);

        
        byte[] data2 = new byte[1024];
        DatagramPacket packet2 = new DatagramPacket(data2, data2.length);
        // 
        while(work) {
            socket.receive(packet2);
            // 
            String reply = new String(data2, 0, packet2.getLength());
            System.out.println("get from server：" + reply);
        }
        // 
        socket.close();
    }
}